﻿/*----------------------------------------------------------------
    // Copyright (C) 2009 江苏华招网
    // 版权所有。 
    // 作者：武双 
    //
    // 文件名：BulidPaymentAdd.cs
    // 文件功能描述：结算管理：新增结算单
    // 创建标识：武双2009-05-12
    //
    // 修改标识：
    // 修改描述：
    //
    // 修改标识：
    // 修改描述：
    //
    // 审核人：
// 审核时间：
// 审核说明：
 //----------------------------------------------------------------*/
using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Collections.Generic;
using HZ.DrugTrade.Web;
using HZ.DrugTrade.Model;
using HZ.DrugTrade.Model.Enum;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.BLLFactory;
namespace HZ.DrugTrade.Web.Hospitals.StorageManage
{
    public partial class PurchaseBuyAnnal : BasePage
    {
        //public PurchaseBuyAnnal()
        //{
        //    this.ModuleNo = Module.采购单管理.ToString();
        //}
        public static string GoodsName;
        IBLL_Statistics iStatistics = Factory.BLL_Statistics ();
        protected void Page_Load ( object sender, EventArgs e )
        {

            if(!IsPostBack)
            {
                Binddata ();
            }
          

            // Model.Query.Distribution dis = new HZ.DrugTrade.Model.Query.Distribution ();
            // dis.CompanyID_PS = "01";
            // dis.HospitalID = "h01";
            // dis.ProcureCatalogID = "2";
            // IBLL_Purchase iPurchase = Factory.BLL_Purchase ();
            // IList<Model.View.Distribution> lstStahosp3 = iPurchase.GetDistribution_Page (dis, 1, 0, out totalrecord);
            // GridView3.DataSource = lstStahosp3;
            // GridView3.DataBind ();
        }

        protected void Binddata ()
        {
            int totalrecord = 0;
            //AspNetPager1.PageSize = Constants.GRIDVIEW_PAGE_SIZE;
            Model.Query.Statistics_Company_Hospit where = new HZ.DrugTrade.Model.Query.Statistics_Company_Hospit ();
            if (CurrentAccount.GetUser().UserID.Substring(0, 2).Equals("QS"))
            {
                where.CompanyID_SC= CurrentAccount.GetUser().Org.OrgID;
            }
            else if (CurrentAccount.GetUser().UserID.Substring(0, 2).Equals("QJ"))
            {
                where.CompanyId_TB = CurrentAccount.GetUser().Org.OrgID;
            }
            else
            {
                where.HospitalID = CurrentAccount.GetUser().Org.OrgID;
            }
            where.CompanyName_SC = txtCompanyName_SC.Text.Trim();
            where.CompanyName_TB = txtCompanyName_TB.Text.Trim();
            where.CompanyName_PS = txtCompany_PS.Text.Trim();
            where.ProcureCatalogID=Request.QueryString["PID"]!=null?Request.QueryString["PID"].ToString():"";
            where.SortFields = " Goodsid";
            IList<Model.View.Statistics_Company_Hospit> lstStahosp = iStatistics.GetStatistics_Company_Hospital (where, this.AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalrecord);
            GoodsName = lstStahosp[0].GoodsName;
            txtGoodsName.Text = GoodsName;
            gvwProduceCatalog.DataSource = lstStahosp;
            gvwProduceCatalog.DataBind ();
            this.AspNetPager1.RecordCount = totalrecord;
        }



        protected void AspNetPager1_OnPageChanged ( object sender, EventArgs e )
        {
            Binddata ();
        }
        protected void btnQuery_Click ( object sender, EventArgs e )
        {
            AspNetPager1.CurrentPageIndex = 1;
            Binddata ();
        }


        protected void lbnSwitch_Click(object sender, EventArgs e)
        {
            if (lbnSwitch.CommandArgument == "simple")
            {
                ltlAdvance.Text = "";
                lbnSwitch.CommandArgument = "advance";
                lbnSwitch.Text = "简单查询";
            }
            else
            {
                ltlAdvance.Text = "<tbody id='advance' style='display:none'>";
                lbnSwitch.CommandArgument = "simple";
                lbnSwitch.Text = "高级查询";

                //清空数据
                txtCompany_PS.Text = "";
                txtCompanyName_SC.Text = "";
                txtCompanyName_TB.Text = "";
                txtGoodsName.Text = "";
            }
        }
    }
}
